using System;
using System.Text;

namespace MM7.MIME
{
	internal class MimeBoundary
	{
		protected static readonly String MimeChars="abcdefghijklmnopqrstuvwxyz0123456789";
		private String _theboundary=null;
		private static Random random=new Random();

		public MimeBoundary()
		{
			_theboundary=MakeMimeBoundary();
		}

		public String BoundaryString
		{
			get 
			{
				return _theboundary;
			}
			set
			{
				_theboundary = value;
			}
		}

		public String BoundaryStringStart
		{
			get 
			{
				return "--"+_theboundary;
			}
		}

		public String BoundaryStringEnd
		{
			get 
			{
				return "--"+_theboundary+"--";
			}
		}

		private String MakeMimeBoundary() 
		{
			int mimelength=32;
			StringBuilder sb=new StringBuilder();
			for (int i=0; i<MimeBoundary.MimeChars.Length; i++) 
			{
				sb.Append(MimeChars[random.Next(mimelength)]);
				
			}
			return "=="+sb.ToString()+"==";
		}


	}
}
